/ Assembly List / LJCDataAccess / DataAccess / GetDataTable

Namespace - LJCDataAccess


Parameters
sql - The Select SQL statement.
tableMapping - The table map collection.

Returns

A reference to the DataTable object.

Syntax

C#
public DataTable GetDataTable(String sql, DataTableMappingCollection tableMapping = null)

Executes a Select statement and retrieves the DataTable object. (E)

Example

C#
// See the DataAccess setup code on the DataAccess class page.

// Executes a Select statement and retrieves the DataTable object.
private static void GetDataTable(DataAccess dataAccess)
{
  string sql = "select * from TableName";

  DataTable dataTable = dataAccess.GetDataTable(sql);
  if (dataTable != null)
  {
    foreach (DataRow dataRow in dataTable.Rows)
    {
      for int index = 0; index < dataTable.Columns.Count; index++)
      {
        string value = dataRow[index].ToString();
      }
    }
  }
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.